note = '''
1. 字典的创建
2. 字典的推导
3. 常见映射方法
4. 用setdefaut处理找不到的键
5. 映射的弹性查询
'''
from collections import defaultdict
# 1
a = dict(one=1, two=2, three=3)
b = {'one': 1, 'two': 2, 'three': 3}
c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
d = dict([('two', 2), ('one', 1), ('three', 3)])
e = dict({'three': 3, 'one': 1, 'two': 2})

# 2
DIAL_CODES = {
    (86, 'China'),
    (91, 'India'),
    (1, 'United States'),
    (62, 'Indonesia'),
    (55, 'Brazil'),
    (92, 'Pakistan'),
    (880, 'Bangladesh'),
    (234, 'Nigeria'),
    (7, 'Russia'),
    (81, 'Japan')
}

country_code = {country: code for code, country in DIAL_CODES}
print(country_code)

country_code = {country.upper(): code for country, code in country_code.items() if code < 61}
print(country_code)

# 4
my_dict = {'a': 1, 'b': 2}
my_dict.setdefault('c', []).append(3)
my_dict.setdefault('d', 4)
my_dict.setdefault('c', 4)
print(my_dict)

# 集合
a, b, c = {}, {1}, set({})
print(type(a), type(b), type(c))